package cn.toys.modular.service.impl;

import cn.toys.base.auth.context.LoginContextHolder;
import cn.toys.base.auth.model.LoginUser;
import cn.toys.base.consts.CommonConstant;
import cn.toys.base.pojo.page.LayuiPageFactory;
import cn.toys.base.utils.SpringBeanSupport;
import cn.toys.modular.entity.*;
import cn.toys.modular.mapper.CityAreaMapper;
import cn.toys.modular.mapper.CompanyExtendInfoMapper;
import cn.toys.modular.mapper.CompanyInfoMapper;
import cn.toys.modular.model.CompanyDto;
import cn.toys.modular.service.ICityAreeaService;
import cn.toys.modular.service.ICompanyService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 区域服务
 *
 * @author guoyu
 * @version 1.0
 * @date 2021/3/9 10:28 上午
 */
@Service
public class CityAreaServiceImpl implements ICityAreeaService {
    @Autowired
    private CityAreaMapper cityAreaMapper;



    @Override
    public List<CityArea> list(CityArea cityArea) {
        CityAreaExample cityAreaExample = new CityAreaExample();
        CityAreaExample.Criteria criteria = cityAreaExample.createCriteria();
        criteria.andStatusCdEqualTo("0");
        if(StringUtils.isNotEmpty(cityArea.getAreaLevel())){
            criteria.andAreaLevelEqualTo(cityArea.getAreaLevel());
        }

        if(cityArea.getAreaCode() != null){
            criteria.andAreaCodeEqualTo(cityArea.getAreaCode());
        }

        if(cityArea.getParentAreaCode() != null){
            criteria.andParentAreaCodeEqualTo(cityArea.getParentAreaCode());
        }
        return cityAreaMapper.selectByExample(cityAreaExample);
    }
}
